package com.wondream.myframework.app.common.util.bbgJwt;

import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class HyException extends Exception {
    private static final long serialVersionUID = 1L;
    private Exception ex;
    private Log logger;

    public HyException(Exception ex) {
        this.ex = ex;
        this.logger = LogFactory.getLog(HyException.class);
    }

    public HyException(Exception ex, Log logger) {
        this.ex = ex;
        this.logger = logger;
    }

    public String getMessage() {
        return this.ex.getMessage();
    }

    public String getLocalizedMessage() {
        return this.ex.getLocalizedMessage();
    }

    public Throwable getCause() {
        return this.ex.getCause();
    }

    public synchronized Throwable initCause(Throwable cause) {
        return this.ex.initCause(cause);
    }

    public String toString() {
        StringWriter sw = new StringWriter();
        this.ex.printStackTrace(new PrintWriter(sw, true));
        return sw.toString();
    }

    public void printStackTrace() {
        StringWriter sw = new StringWriter();
        this.ex.printStackTrace(new PrintWriter(sw, true));
        this.ex.printStackTrace();
    }

    public void printStackTrace(PrintStream s) {
        this.ex.printStackTrace(s);
    }

    public void printStackTrace(PrintWriter s) {
        this.ex.printStackTrace(s);
    }

    public StackTraceElement[] getStackTrace() {
        return this.ex.getStackTrace();
    }

    public void setStackTrace(StackTraceElement[] stackTrace) {
        this.ex.setStackTrace(stackTrace);
    }

    public Log getLogger() {
        return this.logger;
    }
}
